using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Harmony;
using Harmony.ILCopying;
using System.Reflection;

namespace MiaoHarmonyTest
{
    class Program
    {
        static void Main(string[] args)
        {

			//覆写的Harmony机制
			HarmonyInstance harmonyInstance =  HarmonyInstance.Create("MyTestt");
			var addMethod = typeof(Original).GetMethod("Add", BindingFlags.Instance| BindingFlags.Public);
			Original original2 = new Original();
			Func<OriginalValue, OriginalValue> cashe = original2.Add;



			//harmonyInstance.Patch(AccessTools.Method(typeof(Original), "Add"), new HarmonyMethod(typeof(Path), "Add_Prefix"), new HarmonyMethod(typeof(Path), "Add_Postfix"));
			//harmony.Patch(AccessTools.Method(typeof(Original), "Add"),null,new HarmonyMethod(typeof(Path), "Add_Postfix"));

			MethodInfo call = AccessTools.Method(typeof(Original), "Call");
			var call_Prefix = new HarmonyMethod(typeof(Path), "Call_Prefix");

			harmonyInstance.Patch(call, call_Prefix);

			Original.Call();


			//这个代码本身替换做的不是完全覆盖

			//harmonyInstance.Patch(AccessTools.Method(typeof(Original), "UseFuc"), new HarmonyMethod(typeof(Inject), "UseFuc_Prefix"), new HarmonyMethod(typeof(Inject), "UseFuc_Prefix"));
			//harmonyInstance.Patch(AccessTools.Method(typeof(Original), "UseFuc"))

			//Pacth调用
			//Memory.DetourMethod(AccessTools.Method(typeof(Original), "UseFuc"), AccessTools.Method(typeof(Inject), "UseFuc_Prefix"));
			//Memory.WriteJump()
			//不行，这里理解的完全是错的，几个方法获取的

			Original original = new Original();
			//original.Add(new OriginalValue());

			Console.ReadKey();
		}
    }
}
